﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SGT_ON;

public partial class Alerta : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSilenciar_Click(object sender, ImageClickEventArgs e)
    {   
        ImageButton _boton = sender as ImageButton;
        
        if (_boton.CommandArgument == "")
            return;

        int _idAlerta = int.Parse(_boton.CommandArgument);
        SGT_ON.Alerta _alerta = SGT_ON.Alerta.ObtenerPorID(_idAlerta);
        
        if ((_alerta == null)
            || (_alerta.ID <= 0))
            return;

        SGT_ON.ONEmpleado _empleado = SGT_ON.ONEmpleado.ObtenerEmpleadoPorUsuarioID(HttpContext.Current.User.Identity.Name);
        if ((_empleado == null)
            || (_empleado.ID <= 0))
            return;

        _alerta.FechaSilenciada = DateTime.Now;
        _alerta.SilenciadaPor = _empleado.ApellidoYNombre;
        _alerta.Actualizar();

        gvAlertas.DataBind();
    }
    protected void btnBuscar_Click(object sender, EventArgs e)
    {
        gvTodasLasAlertas.DataBind();
    }
}